<html><body bgcolor=pink ><font size=2></font></body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*" %>
<%   Connection con;
     Statement sql; 
     ResultSet rs;
     try{  Class.forName("com.mysql.jdbc.Driver");
     }
     catch(Exception e){
        out.println("忘记把MySQL数据库的JDBC-数据库驱动程序复制到JDK的扩展目录中");
     }
          String uri="jdbc:mysql://127.0.0.1/cj";
          String user="root";
          String password="";
          con=DriverManager.getConnection(uri,user,password);
          sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                 ResultSet.CONCUR_READ_ONLY);
          String s=request.getParameter("sno");
          String na=request.getParameter("name");
          String chi=request.getParameter("chinese");
          String ma=request.getParameter("math");
          String en=request.getParameter("english");
          String ph=request.getParameter("physics");
          String che=request.getParameter("chemistry");
          float c=Float.parseFloat(chi);
          float m=Float.parseFloat(ma);
          float e=Float.parseFloat(en);
          float p=Float.parseFloat(ph);
          float ch=Float.parseFloat(che);
          String condition = "INSERT INTO "+"grade"+" VALUES"+
        	      "("+"'"+s+"','"+na+"','"+c+"','"+m+"','"+e+"','"+p+"','"+ch+"'"+")";
          sql.executeUpdate(condition);
          rs=sql.executeQuery("SELECT * FROM "+"grade");
          ResultSetMetaData metaData = rs.getMetaData();
          int columnCount = metaData.getColumnCount();
          rs.beforeFirst();
          out.print("<br>");
          out.print("<table border=1>");
          out.print("<caption><h1>成绩表</h1></caption>");
          out.print("<tr>");
          out.print("<th width=100>"+"学号");
          out.print("<th width=100>"+"姓名");
          out.print("<th width=100>"+"语文");
          out.print("<th width=100>"+"数学");
          out.print("<th width=100>"+"英语");
          out.print("<th width=100>"+"物理");
          out.print("<th width=100>"+"化学");
          out.print("</tr>");
          int i=0;
          while(rs.next()){
          	out.print("<tr>");
          	for(int k=0;k<columnCount;k++)
          	{
          		out.print("<td >"+rs.getString(k+1)+"</td>");
          		
          	}
          	out.print("</tr>");
          	i++;
          }
          out.print("</table>");
          con.close();
          %>